package com.bird.controller;

import com.bird.po.UserInfo;
import com.bird.service.TestService;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @data 2025/9/15 14:24
 * @author: bird
 * @description: mvc模型中的控制层
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {


    @Resource
    private TestService testService;

    @RequestMapping(method = RequestMethod.GET, value = "/hello")
    @ResponseBody
    public UserInfo hello() {
        String msg = "hello mvc";
        System.out.println("hello");
        UserInfo response = testService.sayHi(msg);
        return response;
    }


    @PostMapping(value = "/add")
    public UserInfo add(@RequestBody UserInfo userInfo) {
        System.out.println("userInfo "+userInfo.toString());
        UserInfo userInfo2 = new UserInfo();
        userInfo2.setName("司军强");
        userInfo2.setAge(345);
        return userInfo2;
    }

    @GetMapping(value = "/delete")
    public UserInfo delete(@RequestParam(value = "name") String name) {
        UserInfo userInfo = new UserInfo();
        userInfo.setAge(23);
        userInfo.setName("熊大");
        return userInfo;
    }

}
